﻿package mortal.game.view.platform
{
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.mvc.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class PlatformShowGirlController extends Controller
    {
        private var _module:PlatformShowGirlModule;

        public function PlatformShowGirlController()
        {
            PlatformShowGirlModule.platformData = PlatformShowGirlUtil.getPanelData();
            return;
        }// end function

        override protected function initView() : IView
        {
            if (this._module == null)
            {
                this._module = new PlatformShowGirlModule();
                this._module.addEventListener(WindowEvent.SHOW, this.onShow);
                this._module.addEventListener(WindowEvent.CLOSE, this.onClose);
            }
            return this._module;
        }// end function

        protected function onShow(event:WindowEvent) : void
        {
            return;
        }// end function

        protected function onClose(event:WindowEvent) : void
        {
            return;
        }// end function

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.LoginGameSuccess, this.onLoginGameSuccess);
            Dispatcher.addEventListener(EventName.PlatformShowGirlShow, this.onPlatformViewShow);
            NetDispatcher.addCmdListener(ServerCommand.ReChargeMoney, this.onReChargeUpdate);
            return;
        }// end function

        protected function onLoginGameSuccess(param1:Object = null) : void
        {
            if (PlatformShowGirlUtil.isNeedShowGirlIcon())
            {
                if (PlatformShowGirlIcon.isViewShow())
                {
                    return;
                }
                PlatformShowGirlIcon.instance.showIconByBtnName(PlatformShowGirlUtil.getIconResName());
            }
            return;
        }// end function

        private function onReChargeUpdate(param1 = null) : void
        {
            if (isViewShow)
            {
                (view as PlatformShowGirlModule).updateShow();
            }
            return;
        }// end function

        private function onPlatformViewShow(event:Event) : void
        {
            if (!isViewShow)
            {
                view.show();
            }
            else
            {
                view.hide();
            }
            return;
        }// end function

    }
}
